<!DOCTYPE HTML>
<html style="background: #f9f9f9">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>我的合同</h2>
      <a href="javascript:void (0);" class="kinds_btn">分类</a>
  </header>
</div>

<section class="contract_section">
    <div class="contract_list">
        <ul id='con'>


        </ul>
    </div>
</section>

<section class="calc_btn">
    <a href="javascript:void (0);" class="go_upload"   onclick="aaplay('contract')">去下载</a>
</section>


<section class="fixed_bg">
    <div class="contract_kinds">
        <div class="news_title">
            <h2>合同分类</h2>
        </div>
        <div class="kinds_list">
            <ul id='cate'>

            </ul>
        </div>
        <div class="contract_btn" style="">
            <a href="javascript:void (0);" class="cancel_btn" onclick="shou()">取消</a>
            <a href="javascript:void (0);" class="sure_btn"  onclick="changetype()">确定</a>
        </div>
    </div>
</section>


</body>

<script>
    var page=0;
    var p='';
    var type=0;
    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        
        api. addEventListener({name:'scrolltobottom'}, function(ret, err){

            toDoRequest();

        });


        cate();
    };
    function toDoRequest(){
        page++;
      p = {
            token: token,
            type: type,
            page: page
        };


        //alert(JSON.stringify(p));
        api.ajax({
            url: webSiteUrl+'/app/user/uhetong',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            //alert(JSON.stringify(ret));

            if(ret.code==200){

                html = "";
                var tj=ret.data;
               // alert(tj.length);

                if(tj != null){

                    for(var i=0;i<tj.length;i++){
                    if(tj[i].status==2){
                        html+='<li style="overflow: hidden;" onclick="myhetongdetail(' + tj[i].tid + ')">';
                    }else{
                        html+='<li style="overflow: hidden;" onclick="myhetongdetail(' + tj[i].tid + ')">';
                    }
                    html+='<a href="javascript:;"><img width="100%" src="'+webSiteUrl+tj[i].icon+'"><div class="info"><h6>'+tj[i].name+'</h6><span>￥'+tj[i].money+'</span></div></a></li>';
                    }
                //alert(html);
                }
                if(page==1){
                    $('#con').html(html);
                }else{
                    $('#con').append(html);
                }
              //  page++;


            }else{
                $('#con').html('<p style="text-align:center; width:100%; height:3rem; line-height:3rem;">暂无数据</p>');

            }
        });

    }

    function myhetongdetail(id) {
        api.openWin({
            name: 'contract_details',
            url: 'contract_details.html',
            reload: true,
            pageParam: {
                id: id,
                my: 1,

            }
        });

    }
    function changetype(){
        shou();
        var id= $(".kinds_list ul").find('.active').attr('data');
        page=0
        type=id
        toDoRequest()

    }

   function cate() {
        var p = {
            type: 114
        };
        api.ajax({
            url: webSiteUrl + '/app/public/cate',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            api.hideProgress();

            if (ret.code == 200) {

                var tj = ret.data;
                var html = "";
                for (var i = 0; i < tj.length; i++) {
                    if (i == 0) {
                        html += '<li class="active" data="' + tj[i].id + '" style="cursor:pointer">' + tj[i].title + '</li>';
                    } else {
                        html += '<li  data="' + tj[i].id + '" style="cursor:pointer">' + tj[i].title + '</li>';
                    }


                }
                $('#cate').html(html);

                toDoRequest()
            }
        });

    }

    //合同搜索
    $(".contract_search input").focus(function () {
        $('.contract_search span').hide()
    });
    $(".contract_search input").blur(function () {
        if($(this).val() ==''){
            $('.contract_search span').show()
        }else {
            $('.contract_search span').hide()
        }
    });
    //合同条件打开
    $(".kinds_btn").click(function () {
        $(".fixed_bg").fadeToggle();
        $(".fixed_bg .contract_kinds").animate({
            'right': '0',
            'opacity': '1'
        },400);
    });
    function shou(){
        $(".fixed_bg").fadeToggle();
        $(".fixed_bg .contract_kinds").animate({
            'right': '-6rem',
            'opacity': '0'
        },400);
    }

    //合同条件搜索
    $(document).on('click',".kinds_list ul li",function(){
        $(this).addClass('active').siblings().removeClass('active');return;
        if($(this).hasClass('active')){
            $(this).removeClass('active');
        }else {
            $(this).addClass('active');
        }
    });
</script>
</html>
